package com.relax.netty.nio;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;

public class NioTest2 {
    public static void main(String[] args) throws Exception {
        FileInputStream fileInputStream = new FileInputStream("a.txt");
        FileChannel channel = fileInputStream.getChannel();

        ByteBuffer byteBuffer = ByteBuffer.allocate(512);
        channel.read(byteBuffer);

        byteBuffer.flip();
//        while (byteBuffer.hasRemaining()){
//            byte b = byteBuffer.get();
//            System.out.println(b);
//        }

        FileOutputStream fileOutputStream = new FileOutputStream("ccc.txt");
        channel = fileOutputStream.getChannel();
        channel.write(byteBuffer);
        fileInputStream.close();
    }
}
